import React from 'react';
import {View, Image, StyleSheet } from 'react-native';
import { Lt, Color, Label, Images, NavTheme as Nav, Jpp, Jx, Touch, Cimage, Fimage, Dialog, Flist, Navigator } from "../_utils";
import { Net, NET_GET } from "../_net"
import { ViewMoments } from './ViewMoments';

export class ApplyMoments extends React.PureComponent{
    constructor(props){
        super(props);
        this.onLoad = this.onLoad.bind(this);
        this.onItem = this.onItem.bind(this);
    }
    static navigationOptions = {
        tabBarIcon : ({focused, tintColor})=><Image source={focused ? Images.quan_2 : Images.quan}/>
    }
    onLoad(params){
        Net.request("other/dayGoods", params.pagination, {params}).then(r=>{
            if(r.data){
                let arr = r.data.pageData;
                params.add(arr.length > 0 ? [arr[0]] : []);
            } else{
                params.add();
            }
        });
    }
    onItem(params){
        const item = params.item;
        return <ViewMoments
            title={item.titile} 
            source={item.image} 
            date={item.createtime}
            // onPress={this.onShare.bind(this,item)}
            content = {item.content}
            images={item.content_Images}
        />
    }
    render(){
        return <View style = {{flex:1, backgroundColor:Color.back}}>
            <Nav.StateBar />
            <View style={{...Nav.style, justifyContent:"center"}}>
                <Nav.TouchTitle title={"朋友圈"}/>
            </View>
            <Flist
                onLoad={this.onLoad}
                onItem={this.onItem}
            />
        </View>;
    }
}